GBML manual / Effects

light_rotate

Points this object’s light: `angle` is in degrees, 0 is east and it turns counterclockwise, the same as this instance’s own `angle` (so 270 is down). The Rotation set in Gbabel is where the light starts. It does nothing on an object that is not set as a light.

Works differently on Game Boy - Turns a light shaped as a cone, a box or a picture, in whole degrees. A Glow does not turn. The Game Boy tells which sprites stand in the shape. Up to 4 lights.

Works differently on Game Boy Color - Turns a light shaped as a cone, a box or a picture, in whole degrees. A Glow has no front and does not turn. The Game Boy Color lights whole 8 by 8 pixel squares. Up to 4 lights, a picture of 3 palettes at most and 4 sprite palettes at most.

Works differently on Sega Genesis - The Sega Genesis has one dark level: half as bright as the picture. Every darkness number above 0 shows that same dark (a room set to 72 is no darker than one set to 50), and 0 is no dark at all. Each light cuts its hole in that dark, in the shape and size set in Gbabel and in the directions and sizes the code asks for; a light's hole is a picture made ahead of time, so a size or a direction the code works out while the game plays is shown as the nearest one made. An object stands in the light as a whole while its middle is in the light. A light near the edge of the screen is whole or gone, and an object lit by room lights keeps its own colors.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

light_rotate(angle)

Arguments

NameType
anglereal

Returns

Nothing.

Description

Points this object's light. angle is in degrees, with the same convention as every other angle in this manual: 0 is east, and it turns counterclockwise, so 90 is up, 180 is west and 270 is straight down. The Rotation you set in Gbabel's Adjust... window is the direction the light starts in; this call turns it from there, while the game runs.

It is the call for a lantern that swings, a flashlight that follows an aim, a lighthouse beam that sweeps, a searchlight, a headlight that turns with the car.

Everything the light does turns with it. The hole it cuts in the room's darkness points the new way, and so does the area it lights on the objects standing in it: an object that was inside the cone and is now outside goes back to its own colors.

What turning does to each shape

A Glow is round, so turning it changes nothing you can see. A Cone and a Box swing about the light's own origin, the point you placed in the Adjust window (a lamp's glass, a flashlight's lens). The origin never moves when the light turns.

The call does nothing on an object whose Lighting setting is not This is a light; Gbabel notes it, and the build goes on.

Example

light_rotate(270 + 25 * btn_dx());

A lamp that points down, and leans to the side the d-pad is held to: 295 when held right, 245 when held left, 270 with nothing held.

A real capture, three pictures of one street lamp whose light is a cone - pointing straight down, then turned a little one way, then a little the otherA real capture, three pictures of one street lamp whose light is a cone - pointing straight down, then turned a little one way, then a little the other
A real capture, three pictures of one street lamp whose light is a cone - pointing straight down, then turned a little one way, then a little the other

On the GBA

A glow looks the same at every angle, so turning it changes nothing you can see; a cone or a box swings about the light’s origin. The hole in the shroud and the objects the light reaches both follow the new direction. A rotated hole is a rotated sprite window, which costs the hardware’s affine matrix a scaled hole already uses, never a second one. The hardware shows a turned picture only up to double its drawn size, so a light whose picture is 64 pixels across should not be thrown farther than the Adjust window’s own limit.

See also: light_onlight_scalelight_flickerRoom lightingshroud_cutout_sprite_angleangle